package top.wardyan.wmes.rfid.pub;

import java.util.List;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.jfinal.core.ActionKey;
import com.jfinal.core.Path;

import top.wardyan.common.ctrl.BaseController;
import top.wardyan.wmes.rfid.kqa.dto.ConterInfoDto;
import top.wardyan.wmes.rfid.kqa.dto.DeviceCmdListDto;
import top.wardyan.wmes.rfid.kqa.vo.BaseRequest;
import top.wardyan.wmes.rfid.kqa.vo.BaseResponse;

/**
 * @author lcf
 * @CreateTime 2022/1/18 9:24
 * @Description 控制器管理
 */
@Path("/conter-info")
@SuppressWarnings("unchecked")
public class ConterInfoController extends BaseController {
	private static final cn.hutool.log.Log log = cn.hutool.log.Log.get();

	@ActionKey("/conter-info/add")
    public void addConterInfo() {
//        BaseResponse<ConterInfoDto> response = new BaseResponse<>();
////        ConterInfoDto conterInfoDto = request.getData();
////        ConterInfoDto dto = conterInfoService.addConterInfo(conterInfoDto);
////        response.setSuccess(dto);
//        this.renderJson(response);
        
        
        
        BaseRequest<ConterInfoDto> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("新增控制器,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<ConterInfoDto> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "{\"conterID\":0,\"conterName\":\"string\",\"endDID\":0,\"gid\":0,\"ip\":\"string\",\"isUse\":0,\"mac\":\"string\",\"model\":0,\"port\":0,\"position\":\"string\",\"protocol\":0,\"remark\":\"string\",\"startDID\":0,\"stationID\":0,\"wirelessPower\":0}";
  		ConterInfoDto dto = JSONObject.parseObject(s, ConterInfoDto.class);
  		response.setData(dto);
  		this.renderJson(response);
    }
	
	
	
	
	
	
	
	
	
	@ActionKey("/conter-info/delete")
    public void delConterInfo() {
//        BaseResponse<String> response = new BaseResponse<>();
////        Integer conterID = request.getData();
////        String msg = conterInfoService.deleteById(conterID);
////        if (!"".equals(msg)) {
////            response.setResult(500, msg);
////            this.renderJson(response);
////        }
////        response.setCode(200);
////        response.setMsg("删除成功");
//        this.renderJson(response);
		

        BaseRequest<Integer> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("删除控制器,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<String> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "OK";
  		response.setData(s);
  		this.renderJson(response);
    }

	@ActionKey("/conter-info/update")
    public void updateConterInfo() {
//        BaseResponse<String> response = new BaseResponse<>();
////        ConterInfoDto conterInfoDto = request.getData();
////        String msg = conterInfoService.updateById(conterInfoDto);
////        if (!"".equals(msg)) {
////            response.setResult(500, msg);
////            this.renderJson(response);
////        }
////        response.setCode(200);
////        response.setMsg("更新成功");
//        this.renderJson(response);

        BaseRequest<ConterInfoDto> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("更新控制器,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<String> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "OK";
  		response.setData(s);
  		this.renderJson(response);
    }
	@ActionKey("/conter-info/get-all-conter-list")
    public void getConterInfoList( ) {
//        BaseResponse<List<ConterInfoDto>> response = new BaseResponse<>();
////        Integer stationID = request.getData();
////        List<ConterInfoDto> dtoList = conterInfoService.getList(null);
////        response.setCode(200);
////        response.setData(dtoList);
//        this.renderJson(response);

        BaseRequest<Integer> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("获取所有控制器信息列表,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<List<ConterInfoDto>> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "[{\"conterID\":0,\"conterName\":\"string\",\"endDID\":0,\"gid\":0,\"ip\":\"string\",\"isUse\":0,\"mac\":\"string\",\"model\":0,\"port\":0,\"position\":\"string\",\"protocol\":0,\"remark\":\"string\",\"startDID\":0,\"stationID\":0,\"wirelessPower\":0}]";
  		List<ConterInfoDto> dto = JSONArray.parseArray(s, ConterInfoDto.class);
  		response.setData(dto);
  		this.renderJson(response);
    }
	@ActionKey("/conter-info/get-station-conter-list")
    public void getStationConterInfoList() {
//        BaseResponse<List<ConterInfoDto>> response = new BaseResponse<>();
////        if (request.getMidId() == null) {
////            response.setResult(500, "参数为空");
////            this.renderJson(response);
////        }
////        List<ConterInfoDto> dtoList = conterInfoService.getList(request.getMidId());
////        response.setCode(200);
////        response.setData(dtoList);
//        this.renderJson(response);

        BaseRequest<Integer> params = this.getJson(BaseRequest.class);
  		if(log.isInfoEnabled()) {
  			log.info("获取站点下控制器信息列表,请求参数为:" + JSONObject.toJSONString(params));
  		}
  		BaseResponse<List<ConterInfoDto>> response = new BaseResponse<>();
  		// response.setSuccess("OK");
  		String s = "[{\"conterID\":0,\"conterName\":\"string\",\"endDID\":0,\"gid\":0,\"ip\":\"string\",\"isUse\":0,\"mac\":\"string\",\"model\":0,\"port\":0,\"position\":\"string\",\"protocol\":0,\"remark\":\"string\",\"startDID\":0,\"stationID\":0,\"wirelessPower\":0}]";
  		List<ConterInfoDto> dto = JSONArray.parseArray(s, ConterInfoDto.class);
  		response.setData(dto);
  		this.renderJson(response);
    }
}
